package com.baturu.vin.honda.dal.dao;

import com.baturu.vin.honda.dto.SEPCHondaPartsColorDTO;
import com.baturu.vin.honda.dto.SEPCHondaPartsInfoDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

/**
 * @Author: chenjiahao
 * @Time: 2019/5/8
 */

public interface SEPCHondaPartsDAO {
    @Select({"SELECT npartgenu,xordergun,nplblk,npl,disk,nplpartref FROM honda_parts_info",
            "WHERE nplblk= #{nplblk}",
            "AND npl = #{npl}",
            "AND disk = #{disk}",})
    List<SEPCHondaPartsInfoDTO> querySEPCPartsInfo(@Param("nplblk") String nplblk, @Param("npl") String npl, @Param("disk") String disk);

    @Select({"<script>SELECT npartgenu,xpartext FROM honda_parts_desc",
            "WHERE npartgenu in ",
            "<foreach item='item' index='index' collection='partsCodes' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "AND disk = #{disk}",
            "</script>"})
    List<SEPCHondaPartsInfoDTO> querySEPCPartsDes(@Param("partsCodes") Collection<String> partsCodes, @Param("disk") String disk);

    @Select({"<script>SELECT partsCode npartgenu,if(epcPartsNameCN='',epcPartsNameEN,epcPartsNameCN) xpartext FROM honda_parts_desc_cn",
            "WHERE partsCode in ",
            "<foreach item='item' index='index' collection='partsCodes' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</script>"})
    List<SEPCHondaPartsInfoDTO> querySEPCPartsDesForCN(@Param("partsCodes") Collection<String> partsCodes);

    @Select({"SELECT npartgenu,nplblk FROM honda_parts_info",
            "WHERE npartgenu = #{partsCode}",
            "AND npl = #{npl}",
            "AND disk = #{disk}",})
    List<SEPCHondaPartsInfoDTO> querySEPCPartsInfoByPartsCode(@Param("partsCode") String partsCode,@Param("npl") String npl, @Param("disk") String disk);

    @Select({"<script>SELECT DISTINCT npartgenu,chescol_ext,CINTECOLTYP FROM honda_ppacot",
            "WHERE npartgenu in ",
            "<foreach item='item' index='index' collection='partsCodes' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "AND disk = #{disk}",
            "AND npl = #{npl}",
            "</script>"})
    List<SEPCHondaPartsColorDTO> querySEPCPartsColor(@Param("partsCodes") Collection<String> partsCodeSet, @Param("npl")String npl,@Param("disk") String disk);

}
